package com.edison.controller;

import brave.Tracer;
import com.edison.democommon.api.ApiResponse;
import com.edison.democommon.api.Metadata;
import com.edison.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author edison
 */
@RestController
@RequestMapping("/service-1")
public class AuthController {

    @Autowired
    private AuthService authService;
    @Resource
    private Tracer tracer;
    @GetMapping("/auth")
    public ApiResponse<Map<String,String>>authenticate(){
        return ApiResponse.success(authService.generateToken(),new Metadata(tracer.currentSpan().context().traceIdString(),String.valueOf(System.currentTimeMillis())));

    }




}
